/**
 * 定时器
 * 
 * @returns
 */
function Timer() {

	// 存放着每张PPT的定时信息，默认为0
	this.hContainer = new Array();
	this.mContainer = new Array();
	this.sContainer = new Array();

	this.add = function(h, m, s) {
		this.hContainer.push(h);
		this.mContainer.push(m);
		this.sContainer.push(s);
	};

	/**
	 * 更新第几个
	 */
	this.update = function(index, h, m, s) {
		this.hContainer[index] = h;
		this.mContainer[index] = m;
		this.sContainer[index] = s;
	};

	/**
	 * 删除该张PPT的定时器 <br>
	 * 更新为0，0，0
	 */
	this.clean = function(index) {
		this.update(index, 0, 0, 0);
	};

	/**
	 * 删除PPT时，定时器也移除
	 */
	this.drop = function(index) {
		this.hContainer.removeByIndex(index);
		this.mContainer.removeByIndex(index);
		this.sContainer.removeByIndex(index);
	};
	/**
	 * 
	 */
	this.moveUp = function(index) {
		if (index <= 0) {
			return;
		}

		// 交换定时器
		var h = this.hContainer[index];
		var m = this.mContainer[index];
		var s = this.sContainer[index];

		this.hContainer[index] = this.hContainer[index - 1];
		this.mContainer[index] = this.mContainer[index - 1];
		this.sContainer[index] = this.sContainer[index - 1];

		this.hContainer[index - 1] = h;
		this.mContainer[index - 1] = m;
		this.sContainer[index - 1] = s;
	};

	/*
	 * 定时器下移
	 */
	this.moveDown = function(index) {
		// 已经是最后一个了
		if (index >= this.hContainer.length - 1) {
			return;
		}

		// 交换定时器
		var h = this.hContainer[index];
		var m = this.mContainer[index];
		var s = this.sContainer[index];

		this.hContainer[index] = this.hContainer[index + 1];
		this.mContainer[index] = this.mContainer[index + 1];
		this.sContainer[index] = this.sContainer[index + 1];

		this.hContainer[index + 1] = h;
		this.mContainer[index + 1] = m;
		this.sContainer[index + 1] = s;

	};

	/**
	 * 计时信息显示
	 */
	this.show = function(index) {
		var h = this.hContainer[index];
		var m = this.mContainer[index];
		var s = this.sContainer[index];
		
		$("#timer-info").html("<h1>有效时间:" + h + "时" + m + "分" + s + "秒</h1>");
	};

	this.getH = function(index) {
		return this.hContainer[index];
	};

	this.getM = function(index) {
		return this.mContainer[index];
	};

	this.getS = function(index) {
		return this.sContainer[index];
	};
}